﻿<Window x:Class="RssReader.Window3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:RssReader"
    Title="Window3" Height="548" Width="421" Background="Transparent"
     xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" Template="{DynamicResource WindowControlTemplate1}">
    <Window.Resources>
    <local:HTMLStringToDocumentConverter x:Key="converter" /> 
    <DataTemplate x:Key="PostTemplate" >      
    <Grid Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type local:ScrollabeListBox}, Mode=FindAncestor}}">
      <Grid.RowDefinitions > 
         <RowDefinition Height="20"/>
        <RowDefinition Height="20"/>
         <RowDefinition Height="Auto" /> 
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <TextBlock Text="{Binding Path=Title}" FontSize="14" FontWeight="Bold" Grid.ColumnSpan="2" />
        <TextBlock Text="{Binding Path=Author}" FontSize="11" Grid.Column="0" Grid.Row="1"/>
        <TextBlock Text="{Binding Path=DatePublished}" FontSize="11" Grid.Column="1" Grid.Row="1"/> 
        <RichTextBox IsReadOnly="True" IsHitTestVisible="True" local:RichTextBoxFlowDocumentSetter.Document="{Binding Path=Description, Converter={StaticResource converter}}" Grid.Row="2"
                     Grid.ColumnSpan="2"
                     VerticalAlignment="Top" HorizontalAlignment="Stretch" MaxHeight="100"  Style="{DynamicResource RichTextBoxStyle1}"
                     Margin="0,0,0,3"/> 
          
      </Grid>
  </DataTemplate>
    <Storyboard x:Key="Storyboard1">
    	<ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Posts" Storyboard.TargetProperty="(FrameworkElement.Margin)">
    		<SplineThicknessKeyFrame KeyTime="00:00:04" Value="0,0,0,0"/>
    	</ThicknessAnimationUsingKeyFrames>
    </Storyboard>
    <SolidColorBrush x:Key="ListBorder" Color="#828790"/>
    <Style x:Key="ListBoxStyle1" TargetType="{x:Type ListBox}">
    	<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
    	<Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
    	<Setter Property="BorderThickness" Value="1"/>
    	<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    	<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
    	<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
    	<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
    	<Setter Property="VerticalContentAlignment" Value="Center"/>
    	<Setter Property="Template">
    		<Setter.Value>
    			<ControlTemplate TargetType="{x:Type ListBox}">
    				<Border x:Name="Bd" SnapsToDevicePixels="true" BorderThickness="{TemplateBinding BorderThickness}" Padding="1">
    					<ScrollViewer Padding="{TemplateBinding Padding}" Focusable="false" local:VerticalOffsetBehavior.Offset="0" x:Name="scrollViewer">
                <ScrollViewer.Resources>
                  <Storyboard x:Key="AnimateScrollViewer">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="scrollViewer" Storyboard.TargetProperty="(local:VerticalOffsetBehavior.Offset)">
                      <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                      <SplineDoubleKeyFrame KeyTime="00:00:20" Value="300"/>
                    </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
                </ScrollViewer.Resources>
    						<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    					</ScrollViewer>
    				</Border>
    				<ControlTemplate.Triggers>
    					<Trigger Property="IsEnabled" Value="false">
    						<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
    					</Trigger>
    					<Trigger Property="IsGrouping" Value="true">
    						<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
    					</Trigger>
    				</ControlTemplate.Triggers>
    			</ControlTemplate>
    		</Setter.Value>
    	</Setter>
    </Style>
    	<LinearGradientBrush x:Key="TextBoxBorder" MappingMode="Absolute" EndPoint="0,20" StartPoint="0,0">
    		<GradientStop Color="#ABADB3" Offset="0.05"/>
    		<GradientStop Color="#E2E3EA" Offset="0.07"/>
    		<GradientStop Color="#E3E9EF" Offset="1"/>
    	</LinearGradientBrush>
    	<Style x:Key="{x:Type TextBoxBase}" BasedOn="{x:Null}" TargetType="{x:Type TextBoxBase}">
    		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
    		<Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}"/>
    		<Setter Property="BorderThickness" Value="0"/>
    		<Setter Property="Padding" Value="0"/>
    		<Setter Property="AllowDrop" Value="false"/>
    		<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    		<Setter Property="Template">
    			<Setter.Value>
    				<ControlTemplate TargetType="{x:Type TextBoxBase}">
    					<Microsoft_Windows_Themes:ListBoxChrome x:Name="Bd" SnapsToDevicePixels="true" BorderThickness="{TemplateBinding BorderThickness}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" RenderMouseOver="{TemplateBinding IsMouseOver}">
    						<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    					</Microsoft_Windows_Themes:ListBoxChrome>
    					<ControlTemplate.Triggers>
    						<Trigger Property="IsEnabled" Value="false">
    							<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
    							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
    						</Trigger>
    					</ControlTemplate.Triggers>
    				</ControlTemplate>
    			</Setter.Value>
    		</Setter>
    	</Style>
    	<Style x:Key="RichTextBoxStyle1" TargetType="{x:Type RichTextBox}">
    		<Style.Resources>
    			<Style x:Key="{x:Type FlowDocument}" TargetType="{x:Type FlowDocument}">
    				<Setter Property="OverridesDefaultStyle" Value="true"/>
    			</Style>
    		</Style.Resources>
    		<Setter Property="MinWidth" Value="10"/>
    		<Style.BasedOn>
    			<StaticResource ResourceKey="{x:Type TextBoxBase}"/>
    		</Style.BasedOn>
    	</Style>
    	<ControlTemplate x:Key="WindowControlTemplate1" TargetType="{x:Type Window}">    		 
    		<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
    			<Grid>
    				<ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
    				<ResizeGrip HorizontalAlignment="Right" x:Name="WindowResizeGrip" VerticalAlignment="Bottom" IsTabStop="False" Visibility="Collapsed"/>
    			</Grid>
    		</Border>
    		<ControlTemplate.Triggers>    			 
    			<MultiTrigger>
    				<MultiTrigger.Conditions>
    					<Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
    					<Condition Property="WindowState" Value="Normal"/>
    				</MultiTrigger.Conditions>
    				<Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
    			</MultiTrigger>
    		</ControlTemplate.Triggers>
    	</ControlTemplate>
    	<Storyboard x:Key="OnMouseEnter1">
    		 <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
    			<SplineColorKeyFrame KeyTime="00:00:00.3000000" Value="#FFF5F0F0"/>
    		</ColorAnimationUsingKeyFrames>
    	</Storyboard>
    	<Style x:Key="BorderStyle1" TargetType="{x:Type Border}">
    		<Style.Resources>
    			<Storyboard x:Key="OnMouseEnter1"/>
    		</Style.Resources>
    		<Style.Triggers>
    			<!-- 
				<Trigger Property="IsMouseOver" Value="True">
					<Setter Property="Background" Value="Red" /> 
				</Trigger>
    			<EventTrigger RoutedEvent="Mouse.MouseEnter">
    				<BeginStoryboard Storyboard="{StaticResource OnMouseEnter1}"/>
    			</EventTrigger> --> 
    		</Style.Triggers>
    	</Style>    	 
  </Window.Resources>
	 
	 
	<!--<Window.Triggers>
		<EventTrigger RoutedEvent="FrameworkElement.Loaded">
			<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
		</EventTrigger>
	</Window.Triggers>-->
    <Grid DataContext="{x:Static local:DesignTimeData.SingleFeed}">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="0.067*"/>
    		<RowDefinition Height="0.933*"/>
    	</Grid.RowDefinitions>
      <Border Background="{DynamicResource BlackToGrayBackground}" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Grid.Row="0" Opacity="0.335">
      	<TextBlock Text="Win 7 RSS Reader (placeholder) " TextWrapping="Wrap" FontSize="18" FontFamily="Jokerman" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFF5821F"/>
      </Border>
      <Border  MouseLeftButtonDown="Border_MouseLeftButtonDown" HorizontalAlignment="Stretch" Margin="0,0,0,1" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Grid.Row="0" Grid.RowSpan="2" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" BorderBrush="#FF696868" x:Name="border" Style="{DynamicResource BorderStyle1}" Background="#00FFFFFF"/>
    <local:ScrollabeListBox x:Name="Posts" Background="#00FFFFFF" 
    ItemTemplate="{StaticResource PostTemplate}" ItemsSource="{Binding Path=Posts}" 
                      Width="400"  Margin="0,0,0,2" Height="Auto" Grid.Row="1" Grid.RowSpan="2" ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                      Style="{DynamicResource ListBoxStyle1}"  />
      <Rectangle HorizontalAlignment="Left" Margin="8,0,0,0" Width="34" Fill="{DynamicResource RSS}"/>
      
  </Grid>
</Window>
